{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {
    "colab_type": "text",
    "id": "JndnmDMp66FL"
   },
   "source": [
    "#### Copyright 2017 Google LLC."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 0,
   "metadata": {
    "cellView": "both",
    "colab": {
     "autoexec": {
      "startup": false,
      "wait_interval": 0
     }
    },
    "colab_type": "code",
    "id": "hMqWDc_m6rUC"
   },
   "outputs": [],
   "source": [
    "# Licensed under the Apache License, Version 2.0 (the \"License\");\n",
    "# you may not use this file except in compliance with the License.\n",
    "# You may obtain a copy of the License at\n",
    "#\n",
    "# https://www.apache.org/licenses/LICENSE-2.0\n",
    "#\n",
    "# Unless required by applicable law or agreed to in writing, software\n",
    "# distributed under the License is distributed on an \"AS IS\" BASIS,\n",
    "# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n",
    "# See the License for the specific language governing permissions and\n",
    "# limitations under the License."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "colab_type": "text",
    "id": "cH-YtyZs7Gcg"
   },
   "source": [
    "# 准备工作：Hello World"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "colab_type": "text",
    "id": "r0QBC2kTixPn"
   },
   "source": [
    "**学习目标：**在浏览器中运行 TensorFlow 程序。"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "colab_type": "text",
    "id": "33fL46pgixPo"
   },
   "source": [
    "以下代码块为“Hello World”TensorFlow 程序。\n",
    "\n",
    "其中包含初始化代码（导入 TensorFlow 模块并启用“eager execution”，我们将在后续练习中详细介绍此操作），然后输出“Hello, world!”字符串常量。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 0,
   "metadata": {
    "cellView": "both",
    "colab": {
     "autoexec": {
      "startup": false,
      "wait_interval": 0
     }
    },
    "colab_type": "code",
    "id": "bRuPN7qo7ICp"
   },
   "outputs": [],
   "source": [
    "from __future__ import print_function\n",
    "\n",
    "import tensorflow as tf\n",
    "try:\n",
    "  tf.contrib.eager.enable_eager_execution()\n",
    "except ValueError:\n",
    "  pass  # enable_eager_execution errors after its first call\n",
    "\n",
    "tensor = tf.constant('Hello, world!')\n",
    "tensor_value = tensor.numpy()\n",
    "print(tensor_value)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "colab_type": "text",
    "id": "Bl1nAshab6m5"
   },
   "source": [
    "## 要运行此程序，请执行以下操作\n",
    "\n",
    "  1. 点击代码块中的任意位置（例如，点击字词 `import`）。\n",
    "\n",
    "  2. 点击代码块左上角的右向三角图标，或按 ⌘/Ctrl+Enter 键。\n",
    "\n",
    "     程序需要几秒钟才会运行。如果一切顺利，程序会在代码块正下方显示 `Hello, world!` 字样\n",
    "\n",
    "整个程序仅包含一个代码块。不过，大部分练习都会包含多个代码块，在这种情况下，您应**按从上到下的顺序逐个运行代码块。**\n",
    "\n",
    "不按顺序运行代码块通常会导致错误。"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "colab_type": "text",
    "id": "UpzZ0Gv-uKf_"
   },
   "source": [
    "## 实用的键盘快捷键\n",
    "\n",
    "* **⌘/Ctrl+m,b：**在当前选择的单元格下方创建一个空白代码单元格\n",
    "* **⌘/Ctrl+m,i：**中断单元格的运行\n",
    "* **⌘/Ctrl+m,h：**显示所有键盘快捷键列表\n",
    "* 要查看关于任何 TensorFlow API 方法的文档，请将光标放置在其左括号的正后方，然后按 **Tab** 键：\n",
    "\n",
    "  ![TensorFlow tf.constant 方法的弹出式文档](https://download.mlcc.google.cn/mledu-images/tf_pop_up_doc_example.png)"
   ]
  }
 ],
 "metadata": {
  "colab": {
   "collapsed_sections": [
    "JndnmDMp66FL"
   ],
   "default_view": {},
   "name": "hello_world.ipynb",
   "provenance": [],
   "version": "0.3.2",
   "views": {}
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}
